package com.tubang.logistics.util;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class DateUtils {

	/**
	 * 返回一个 yyyy-MM-dd HH:mm:ss 类型的时间字符串 (exp. 2017-02-08 11:14:16)
	 *
	 * @param timestamp 时间戳
	 * @return
	 */
	public static String getyyyyMMddHHmmss(Date timestamp) {
		if (null == timestamp) {
			return null;
		}
		LocalDateTime shanghai = timestamp.toInstant().atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime();
		return shanghai.format(DateTimeFormatter.ofPattern("yyyy-MM-dd  HH:mm:ss"));
	}

	/**
	 * 现在的年月日 2017/08/16 格式
	 *
	 * @return
	 */
	public static String getYearMonthDayNow() {
		return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
	}
}
